Skip to content

[lldp] Fix LLDP_ENTRY_TABLE key comparison for dualtor topology#23193

Merged
StormLiangMS merged 1 commit intosonic-net:masterfrom
ZhaohuiS:fix/lldp-syncd-deduplicate-fanout-neighbors
Mar 24, 2026
Merged

[lldp] Fix LLDP_ENTRY_TABLE key comparison for dualtor topology#23193
StormLiangMS merged 1 commit intosonic-net:masterfrom
ZhaohuiS:fix/lldp-syncd-deduplicate-fanout-neighbors

Conversation

@ZhaohuiS
Copy link
Copy Markdown
Contributor

Description of PR

Summary:
Fix test_lldp_entry_table_content failure on dualtor-aa topology caused by duplicate LLDP neighbors from fanout switches.

In dualtor-aa topology, uplink ports (e.g., Ethernet224/232/240) receive LLDP PDUs from both the T1 ARISTA switch and the fanout switch. show lldp table lists multiple rows per port, but LLDP_ENTRY_TABLE in APPL_DB stores only one entry per interface. The sorted list comparison (29 DB keys vs 32 CLI rows) always fails.

Fixes https://msazure.visualstudio.com/One/_workitems/edit/36796797

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

test_lldp_entry_table_content consistently fails on dualtor-aa topology testbeds (e.g., Arista-720DT-48CQ, Cisco-8101-C32) because get_show_lldp_table_output() returns duplicate interface entries when a port has multiple LLDP neighbors.

Example from show lldp table on dualtor-aa:

Ethernet224  ARISTA01T1           Ethernet2       BR       <- T1 neighbor
Ethernet224  str3-8101-fanout-10  etp28a          BR       <- fanout neighbor (duplicate!)

The comparison sorted(lldp_entry_keys) == sorted(show_lldp_table_int_list) fails because:

  • LLDP_ENTRY_TABLE has 29 unique interface keys
  • show lldp table parsed output has 32 entries (3 interfaces duplicated due to fanout)

How did you do it?

  1. Deduplicate in get_show_lldp_table_output(): Use dict.fromkeys() to remove duplicate interface names while preserving order
  2. Use set comparison in check_lldp_table_keys(): Replace sorted() list comparison with set() comparison for robustness
  3. Improve error message in assert_lldp_interfaces(): Use set comparison and include diff details (which interfaces are in DB but not CLI, and vice versa) for easier debugging

How did you verify/test it?

  • Analyzed actual failure logs from dualtor-aa testbed (str3-8101c1-08, Arista-720DT topology)
  • Confirmed that Ethernet224, Ethernet232, Ethernet240 each appear twice in show lldp table (once for T1 neighbor ARISTA0xT1, once for fanout str3-8101-fanout-10)
  • Verified that the fix correctly deduplicates and uses set comparison

Any platform specific information?

Affects dualtor-aa topology testbeds where uplink ports are connected through fanout switches that also advertise LLDP. Confirmed on:

  • Arista-720DT-48CQ (dualtor-aa)
  • Cisco-8101-C32 (dualtor-aa)

Supported testbed topology if it's a new test case?

N/A (bug fix for existing test)

Documentation

N/A

In dualtor-aa topology, uplink ports receive LLDP PDUs from both
the T1 neighbor switch and the fanout switch. This causes
`show lldp table` to list multiple rows per interface (e.g.,
Ethernet224 appears twice - once for ARISTA01T1, once for fanout).

The test compared sorted lists of interfaces from APPL_DB
LLDP_ENTRY_TABLE (which stores one entry per interface) against
the parsed `show lldp table` output (which has duplicate entries).
This always failed on dualtor testbeds (29 DB keys vs 32 CLI rows).

Changes:
- Deduplicate interface list in get_show_lldp_table_output() using
  dict.fromkeys() to handle multiple LLDP neighbors per port
- Use set comparison instead of sorted list comparison in
  check_lldp_table_keys() and assert_lldp_interfaces()
- Add diff details to assertion error message for easier debugging

Signed-off-by: Zhaohui Sun <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Collaborator

@StormLiangMS StormLiangMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — correct fix for dualtor LLDP test. dict.fromkeys() for dedup and set comparison with diff-based error messages are clean improvements. CI all green.

@StormLiangMS StormLiangMS merged commit 2d72da4 into sonic-net:master Mar 24, 2026
17 checks passed
@StormLiangMS StormLiangMS added the Request for 202511 branch Request to backport a change to 202511 branch label Mar 24, 2026
ravaliyel pushed a commit to ravaliyel/sonic-mgmt that referenced this pull request Mar 27, 2026
…c-net#23193)

In dualtor-aa topology, uplink ports receive LLDP PDUs from both
the T1 neighbor switch and the fanout switch. This causes
`show lldp table` to list multiple rows per interface (e.g.,
Ethernet224 appears twice - once for ARISTA01T1, once for fanout).

The test compared sorted lists of interfaces from APPL_DB
LLDP_ENTRY_TABLE (which stores one entry per interface) against
the parsed `show lldp table` output (which has duplicate entries).
This always failed on dualtor testbeds (29 DB keys vs 32 CLI rows).

Changes:
- Deduplicate interface list in get_show_lldp_table_output() using
  dict.fromkeys() to handle multiple LLDP neighbors per port
- Use set comparison instead of sorted list comparison in
  check_lldp_table_keys() and assert_lldp_interfaces()
- Add diff details to assertion error message for easier debugging

Signed-off-by: Zhaohui Sun <[email protected]>
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Mar 30, 2026
…c-net#23193)

In dualtor-aa topology, uplink ports receive LLDP PDUs from both
the T1 neighbor switch and the fanout switch. This causes
`show lldp table` to list multiple rows per interface (e.g.,
Ethernet224 appears twice - once for ARISTA01T1, once for fanout).

The test compared sorted lists of interfaces from APPL_DB
LLDP_ENTRY_TABLE (which stores one entry per interface) against
the parsed `show lldp table` output (which has duplicate entries).
This always failed on dualtor testbeds (29 DB keys vs 32 CLI rows).

Changes:
- Deduplicate interface list in get_show_lldp_table_output() using
  dict.fromkeys() to handle multiple LLDP neighbors per port
- Use set comparison instead of sorted list comparison in
  check_lldp_table_keys() and assert_lldp_interfaces()
- Add diff details to assertion error message for easier debugging

Signed-off-by: Zhaohui Sun <[email protected]>
Signed-off-by: mssonicbld <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202511: #23435

mssonicbld added a commit that referenced this pull request Mar 30, 2026
…) (#23435)

In dualtor-aa topology, uplink ports receive LLDP PDUs from both
the T1 neighbor switch and the fanout switch. This causes
`show lldp table` to list multiple rows per interface (e.g.,
Ethernet224 appears twice - once for ARISTA01T1, once for fanout).

The test compared sorted lists of interfaces from APPL_DB
LLDP_ENTRY_TABLE (which stores one entry per interface) against
the parsed `show lldp table` output (which has duplicate entries).
This always failed on dualtor testbeds (29 DB keys vs 32 CLI rows).

Changes:
- Deduplicate interface list in get_show_lldp_table_output() using
  dict.fromkeys() to handle multiple LLDP neighbors per port
- Use set comparison instead of sorted list comparison in
  check_lldp_table_keys() and assert_lldp_interfaces()
- Add diff details to assertion error message for easier debugging

Signed-off-by: Zhaohui Sun <[email protected]>
Signed-off-by: mssonicbld <[email protected]>
Co-authored-by: Zhaohui Sun <[email protected]>
selldinesh pushed a commit to selldinesh/sonic-mgmt that referenced this pull request Apr 1, 2026
…c-net#23193)

In dualtor-aa topology, uplink ports receive LLDP PDUs from both
the T1 neighbor switch and the fanout switch. This causes
`show lldp table` to list multiple rows per interface (e.g.,
Ethernet224 appears twice - once for ARISTA01T1, once for fanout).

The test compared sorted lists of interfaces from APPL_DB
LLDP_ENTRY_TABLE (which stores one entry per interface) against
the parsed `show lldp table` output (which has duplicate entries).
This always failed on dualtor testbeds (29 DB keys vs 32 CLI rows).

Changes:
- Deduplicate interface list in get_show_lldp_table_output() using
  dict.fromkeys() to handle multiple LLDP neighbors per port
- Use set comparison instead of sorted list comparison in
  check_lldp_table_keys() and assert_lldp_interfaces()
- Add diff details to assertion error message for easier debugging

Signed-off-by: Zhaohui Sun <[email protected]>
Signed-off-by: selldinesh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants